<template>
  <div>
    <div class="page_title">参建单位名单库{{}}</div>
    <FormTable :name="table.name" :formRules="formRules" :tableData="table.tableData" :columns="table.columns"
      :total="total" :currentPage="queryParams.pageNum" :pageSize="queryParams.pageSize" @changeTableData="changeTableData"
      @queryTable="queryTable">
      <template #operator="{ slotProps }" class="table_button_list">
        <span class="table_button" @click="goToDetail(slotProps)">查看</span>
      </template>
    </FormTable>
  </div>
</template>
<script name="list-two" setup>
import FormTable from "@/components/FormTable/index.vue";
import { useRouter } from "vue-router";
import { getList as getCompanyList } from '@/api/company'
import { jianGuanFengXian,belongDomain } from "@/utils/enum";
const router = useRouter();
let total = ref(0);
let queryParams = reactive({ pageNum: 1, pageSize: 10, groups: [], rules: [], orderBys: [] })

onMounted(() => {
  getList()
})
function getList() {
  getCompanyList(queryParams).then(res => {
    table.tableData = res.data.list
    total.value = res.data.total
  })
}
function queryTable(params) {
  let rules = []
  for (let key in params) {
    let val = params[key]
    val && rules.push(
      {
        field: key,
        data: val,
        opType: "Contains"
      }
    )
  }
  queryParams.rules = rules
  getList()
}
const table = reactive({
  tableData: [],
  name: "参建单位名单列表",
  columns: [
    {
      label: "序号",
      type: "index",
      width: '70px'
    },
    {
      label: "单位名称",
      prop: "enterpriseName",
    },
    {
      label: "统一信用代码",
      prop: "unifiedCreditCode",
    },
    {
      label: "地址",
      prop: "address",
    },
    {
      label: "联系人",
      prop: "contact",
    },
    {
      label: "联系电话",
      prop: "telephone",
    },
    {
      label: "监管风险等级",
      prop: "superviseRiskLevel",
    },
    {
      label: "所属领域",
      prop: "belongDomain",
    },
    {
      prop: "operator",
      label: "操作",
    },
  ],
  totalRecordCount: 10,
  sortable: {},
});
const formRules = ref([
  {
    type: "input",
    field: "enterpriseName",
    title: "名称",
    value: "",
  },
  {
    type: "input",
    field: "unifiedCreditCode",
    title: "统一信用代码",
    value: "",
  },
  {
    type: "input",
    field: "address",
    title: "地址",
    value: "",
  },
  {
    type: "input",
    field: "contact",
    title: "联系人",
    value: "",
  },
  {
    type: "input",
    field: "telephone",
    title: "联系电话",
    value: "",
  },
  {
    type: "select",
    field: "superviseRiskLevel",
    title: "监管风险等级",
    value: "",
    options: jianGuanFengXian
  },
  {
    type: "select",
    field: "belongDomain",
    title: "所属领域",
    value: "",
    options: belongDomain
  },
]);
const goToDetail = (props) => {
  router.push({ path: "/company/detail", query: { id: props.id } });
}
</script>
<style lang="scss" scoped></style>